<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="/build/snarkjs.js"></script>
    <script type="importmap">
      {
        "imports": {
          "ffjavascript": "../node_modules/ffjavascript/build/browser.esm.js"
        }
      }
    </script>
  </head>
  <body>
    <script type="module">
      async function testBrowserBuilds(build) {
        const ptau_final =
          "https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_10.ptau";
        const r1cs = "/test/circuit/circuit.r1cs";
        const wasm = "/test/circuit/circuit.wasm";
        const zkey_0 = { type: "mem" };
        const zkey_1 = { type: "mem" };
        const zkey_final = { type: "mem" };
        const wtns = { type: "mem" };

        await build.zKey.newZKey(r1cs, ptau_final, zkey_0);

        await build.zKey.contribute(zkey_0, zkey_1, "p2_C1", "pa_Entropy1");

        await build.zKey.beacon(
          zkey_1,
          zkey_final,
          "B3",
          "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20",
          10
        );

        const verifyFromR1csResult = await build.zKey.verifyFromR1cs(
          r1cs,
          ptau_final,
          zkey_final
        );
        console.assert(verifyFromR1csResult);

        const verifyFromInit = await build.zKey.verifyFromInit(
          zkey_0,
          ptau_final,
          zkey_final
        );
        console.assert(verifyFromInit);

        const vKey = await build.zKey.exportVerificationKey(zkey_final);

        await build.wtns.calculate({ a: 11, b: 2 }, wasm, wtns);

        await build.wtns.check(r1cs, wtns);

        const { proof, publicSignals } = await build.groth16.prove(
          zkey_final,
          wtns
        );

        const verified = await build.groth16.verify(vKey, publicSignals, proof);
        console.assert(verified);
      }

      await testBrowserBuilds(snarkjs);
      const esmBuild = await import("/build/browser.esm.js");
      await testBrowserBuilds(esmBuild);
      shutdown();
    </script>
  </body>
</html>

<head> </head>

<body></body>
